// pages/specify/specify.js
const utils = require('../../utils/util.js');
const post = utils.post;
const getCurrentPageUrlWithArgs = utils.getCurrentPageUrlWithArgs;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [
      {
        id: 0,
        title: "试玩或者分享小程序赚钱是真是的吗？怎么玩？",
        content: '../../image/specify_1.png',
        selectedFlag: false,
        conif: false
      },
      {
        id: 1,
        title: "怎么样才能赚更多？",
        content: '../../image/specify_2.png',
        selectedFlag: false,
        conif: false
      },
      {
        id: 2,
        title: "为什么试玩后没有收益？",
        content: '../../image/specify_3.png',
        selectedFlag: false,
        conif: true
      },
      {
        id: 3,
        title: "收益是怎么计算的？",
        content: '../../image/specify_4.png',
        selectedFlag: false,
        conif: false
      },
      {
        id: 4,
        title: "提现是打到哪里？",
        content: '../../image/specify_5.png',
        selectedFlag: false,
        conif: false
      },
      {
        id: 5,
        title: "什么情况下回提现失败？",
        content: '../../image/specify_6.png',
        selectedFlag: false,
        conif: false
      },
      {
        id: 6,
        title: "任务就这么多吗？",
        content: '../../image/specify_7.png',
        selectedFlag: false,
        conif: false
      },
      {
        id: 7,
        title: "如何联系在线客服？",
        content: '../../image/specify_8.png',
        selectedFlag: false,
        conif: false
      },
      {
        id: 8,
        title: "我如何才能获得更多的徒弟？",
        content: '../../image/specify_9.png',
        selectedFlag: false,
        conif: false
      }

    ],
    ij: 0,
    indexT: 0
    // 展开折叠
  },
  changeToggle: function (e) {
    let that = this;
    var index = e.currentTarget.id;
    for (var i = 0; i < that.data.list.length; i++) {
      if (index == i) {
        if (that.data.list[i].selectedFlag == true) {
          that.data.list[i].selectedFlag = false;
        } else {
          that.data.list[i].selectedFlag = true;
        }
      } else {
        that.data.list[i].selectedFlag = false;
      }
    }
    var list_new = that.data.list
    that.setData({
      list: list_new
    })
    // console.log(that.data.list)
    // if (that.data.ij != 0) {
    //   var hahah = that.data.ij
    //   var itit = `list[${hahah}].selectedFlag`;
    // } else {

    // }
    // var iti = "list[" + index + "].selectedFlag";
    // var iti = `list[${index}].selectedFlag`;
    // that.setData({
    //   [iti]: true,
    //   [itit]: false,
    //   ij: 1,
    //   indexT: index
    // })

  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  /*onShareAppMessage: function () {

  },*/
  submitFormId(e) {
    let formId = e.detail.formId;
    let button = e.detail.target.dataset.name;
    var m_uid = wx.getStorageSync("m_uid");
    let page = getCurrentPageUrlWithArgs();
    let p = {
      m: 'colform',
      uid: m_uid,
      openid: wx.getStorageSync('weapp_openid'),
      formId: formId,
    }
    if (page && page.length > 0) {
      p.page = page;
    }
    if (button && button.length > 0) {
      p.button = button;
    }
    //console.log(p);
    post(p).then(res => {
    })
  }
})